#{extends 'Admin_main.html' /}
<div class="block span10" style="margin-left: 20px;">
    <a href="#tablewidget" class="block-heading" data-toggle="collapse">菜单管理</a>
    <div class="btn-toolbar" style="margin-left: 20px;">

        <a href="" class="btn btn-primary">导入</a>
        <a href="" class="btn btn-primary">导出</a>
     
        <a href="#myModal1" data-toggle="modal" class="btn btn-primary">发送短信</a>

        <div class="btn-group">
        </div>
    </div>
    <div id="tablewidget" class="block-body collapse in">
        <table class="table table-bordered table-striped">
            <tr>
                <th></th>
                <td>编号</td>
                <td>用户名</td>
                <td>身份证信息</td>
                <td>短信信息</td>
                <td>电话</td>
                <td>浏览数</td>
                <td>模板数</td>
            </tr>
        #{list list,as:'list'}
            <tr>
                <td><input type="checkbox" class="caozuo" value="${list.Id}"></td>
                <td>
                    #{if list.Id == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.Id}
                    #{/else}
                </td>
                <td>
                    #{if list.Name == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.Name}
                    #{/else}
                </td>
                <td>
                    #{if list.IDS == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.IDS}
                    #{/else}
                </td>
                <td>
                    #{if list.Email == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.Email}
                    #{/else}
                </td>
                <td>
                    #{if list.IPone == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.IPone}
                    #{/else}
                </td>
                <td>
                    #{if list.Balance == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.Balance}
                    #{/else}
                </td>
                <td>
                    #{if list.Header == null}
                        暂无数据
                    #{/if}
                    #{else }
                    ${list.Header}
                    #{/else}
                </td>

            </tr>
        #{/list}
        </table>
    </div>
</div>
<div class="modal small hide fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel0">发送短信</h3>
    </div>
    <div class="modal-body">
        <div class="bodys">
            <p>请输入内容：</p>
            <p>
                <textarea style="height: 200px;" id="msg"></textarea>
            </p>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        <a href="#myModal2" data-toggle="modal" class="btn btn-primary" data-dismiss="modal" onclick="demo()" >发送</a>
    </div>
</div>
<div class="modal small hide fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel1">正在发送</h3>
    </div>
    <div class="modal-body" id="bodys">

    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        <button class="btn btn-primary" data-dismiss="modal">确定</button>
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
    function demo(){

        var msg = document.getElementById("msg");
        if ($.isEmptyObject(msg.value))  {
            document.getElementById("myModalLabel1").innerHTML = "发送失败";
            var content = " <p>请检查短信内容，该项不得为空</p>";
            document.getElementById("bodys").innerHTML = content;
        }else{
            if ($(".caozuo")[0].checked) {
                $(".caozuo").each(function(){
                    var a =$(this).val();
                    $.ajax({
                        type: "GET",
                        url: "/Admin/IPones.html?id="+a+"&msg="+msg.value,

                        dataType: "json",
                        success: function(data){
                            if(data.code == 1){
                                document.getElementById("myModalLabel1").innerHTML = "发送成功";
                                var content = " <p>发送短信成功，请注意查收</p>";
                                document.getElementById("bodys").innerHTML = content;
                            }else if(data.code == 0){
                                document.getElementById("myModalLabel1").innerHTML = "发送成功";
                                var content = " <p>发送短信失败，请注意检查短信地址</p>";
                                document.getElementById("bodys").innerHTML = content;
                            }
                        }

                    });
                })
            }else{
                document.getElementById("myModalLabel1").innerHTML = "发送失败";
                var content = " <p>请检查是否选择了用户，该项不得为空</p>";
                document.getElementById("bodys").innerHTML = content;
            }

        }



    }

</script>

